package com.speech.utils;

public class SuperMissionUtil {
    // 不能静态SharedPreferenceHelper，因为和context有关

    private static final int[] iarr_LevelSentence = {20, 50, 100, 300, 800, 2000, 5000, 12500};

    public static Integer getMissionBeginNum() {

        int iTotalRead = PropertyAndUserInfoHolder.getTotalReadSentence();
        int index = iarr_LevelSentence.length - 1;
        while (index >= 0 && iTotalRead < iarr_LevelSentence[index]) {
            index--;
        }

        int irst = 0;
        if (index >= 0) {
            irst = iarr_LevelSentence[index];
        }

        return irst;
    }

    public static Integer getMissionEndNum() {

        int iTotalRead = PropertyAndUserInfoHolder.getTotalReadSentence();
        int index = 0;
        while (index<iarr_LevelSentence.length && iTotalRead >= iarr_LevelSentence[index]) {
            index++;
        }

        int irst = iarr_LevelSentence[iarr_LevelSentence.length-1];
        if(index<iarr_LevelSentence.length){
            irst = iarr_LevelSentence[index];
        }

        return irst;
    }

    /**
     * 需要通过 （读过的句子总数 - 任务开始句子数） 来得到当前任务的进度
     *
     * @param iBeginNum
     * @return
     */
    public static Integer getMissionCurrentNum(Integer iBeginNum) {
        int iNum = PropertyAndUserInfoHolder.getTotalReadSentence() - iBeginNum;
        if (iNum < 0) {
            iNum = 0;
        }

        return iNum;
    }

}
